//
//  StatusToolBar.swift
//  weibobbaj
//
//  Created by Tiffany宝 on 16/4/21.
//  Copyright © 2016年 Tiffany. All rights reserved.
//

import UIKit

class StatusToolBar: UIView {
    
    override init(frame: CGRect) {
        
        super.init(frame: frame)
        setupUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    private func setupUI(){
        
//        backgroundColor = RandomColor
        
        let remark = loadButton("timeline_icon_comment",title: "评论")
        let retweet = loadButton("timeline_icon_retweet",title: "转发")
        let like = loadButton("timeline_icon_unlike",title: "赞")
        
        //添加控件
//        addSubview(remark)
//        addSubview(retweet)
//        addSubview(like)
        
        addSubview(sp1);addSubview(sp2)
        
        //添加约束
        retweet.snp_makeConstraints { (make) -> Void in
            
            make.top.leading.bottom.equalTo(self)
            make.width.equalTo(remark)
        }
        
        remark.snp_makeConstraints { (make) -> Void in
            
            make.top.bottom.equalTo(retweet)
            make.leading.equalTo(retweet.snp_trailing)
            make.width.equalTo(like)
        }
        
        like.snp_makeConstraints { (make) -> Void in
            
            make.top.bottom.equalTo(remark)
            make.leading.equalTo(remark.snp_trailing)
            make.trailing.equalTo(self)
//            make.width.equalTo(remark)
        }
        
        sp1.snp_makeConstraints { (make) -> Void in
            
            make.centerY.equalTo(retweet)
            make.leading.equalTo(retweet.snp_trailing)
        }
        
        sp2.snp_makeConstraints { (make) -> Void in
            
            make.centerY.equalTo(remark)
            make.leading.equalTo(remark.snp_trailing)
        }
    }
    
    //懒加载控件
    private lazy var sp1: UIImageView = UIImageView(image: UIImage(named: "timeline_card_bottom_line"))
    private lazy var sp2: UIImageView = UIImageView(image: UIImage(named: "timeline_card_bottom_line"))
    
    private func loadButton(imageName: String,title: String) -> UIButton{
//    private lazy var tbButton: UIButton = {
        
        let button = UIButton(titleColor: UIColor.darkGrayColor(), titleFont: 12, imageName: "timeline_card_bottom_background")
        
        button.setBackgroundImage(UIImage(named: "timeline_card_bottom_background_highlighted"), forState: .Highlighted)
        
        button.setTitle(title, forState: UIControlState.Normal)
        button.setImage(UIImage(named: imageName), forState: .Normal)
        
        //添加控件
        addSubview(button)
        
        return button
//    }()
    }
}
